package org.test.device.architecture.actions;



import org.test.device.architecture.CommonEntity;

import java.util.HashMap;
import java.util.Map;

/**
 * 〈〉<br>
 *
 * @author Mr.Wang
 * @create 2024/9/9
 */
public abstract class BaseActionContext implements ActionContext{

    private CommonEntity doc;

    private final Map<String, Object> paramsMap = new HashMap<>();

    private final Map<String, Object> resultMap = new HashMap<String, Object>();

    public BaseActionContext() {

    }

    public BaseActionContext(final CommonEntity doc) {
        this.doc = doc;
    }

    @Override
    public Map<String, Object> getResultMap() {
        return new HashMap<String, Object>(resultMap);
    }

    @Override
    public Object getResultValue(final String key) {
        return resultMap.get(key);
    }

    @Override
    public void setResult(final String key, final Object value) {
        resultMap.put(key, value);
    }

    @Override
    public void setAllResult(final Map<String, Object> map) {
        resultMap.putAll(map);
    }

    @Override
    public CommonEntity getDoc() {
        return doc;
    }

    @Override
    public void setDoc(final CommonEntity doc) {
        this.doc = doc;
    }

    public Map<String, Object> getParamsMap() {
        return paramsMap;
    }
}